import request from "./request.js"
import qs from 'qs'
// 首页精品推荐数据请求
export const JingpinApi = () => request.get('/products/recommend')

// 微信登录（这个接口必须用qs对数据进行格式化）
export const WeixinLoginApi = (params) => request.post(`/wechatUsers/PCLogin`, qs.stringify(params))

export const getVerifyApi = phone => request.post("/sendSMS", `phone=${phone}`)

export const phoneLoginApi = data => request.post("/phoneRegin", `verifyCode=${data.code}&phone=${data.phone}`)

export const getUserInfoApi = () => request.get('/shop/userProfiles')


export const WXloginApi = code => request.post('/wechatUsers/PCLogin', `code=${code}`)

// 获取精品推荐的数据
export const getRecommendApi = () => request.get('/products/recommend')
// 获取热门兑换的数据
export const getHotListApi = () => request.get('/products/hot')
// 固定用法，详细看axios文档  get请求
export const getMoreApi = params => request.get('/products', {
    params
})
export const addToCarApi = params => request.post('/shop/carts/add', qs.stringify(params))

export const getGoodDetailApi = params => request.get(`/products/${params}`)

export const  getCartDataApi =()=>request.get('/shop/carts')

// 在 axios 里面，使用的 http 2.0 的标准
// 在http 1.0 里面,只有get、post两个请求方式，后来觉得不够
// 在http 2.0 里面新增两个请求方式 ：put / delete
// get - 查 ， post - 增 ， put - 改 , delete - 删
export const deleteCartDataApi = id=> request.delete(`/shop/carts?productIds=${id}`)
                                   

             